home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / system-tools-backends-2.0 / scripts / Platform.pm < prev    next >
Encoding:
Perl POD Document  |  2009-04-09  |  2.2 KB  |  86 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3. # DBus object for the Services config
  4. #
  5. # Copyright (C) 2005 Carlos Garnacho
  6. #
  7. # Authors: Carlos Garnacho Parro  <carlosg@gnome.org>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Library General Public License as published
  11. # by the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU Library General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Library General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23. package Platform;
  24.  
  25. use base qw(Net::DBus::Object);
  26. use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX . ".Platform");
  27. use Utils::Platform;
  28. use Utils::Backend;
  29. use Utils::DBus;
  30.  
  31. my $OBJECT_NAME = "Platform";
  32. my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME";
  33.  
  34. dbus_method ("getPlatformList", [], [[ "array", [ "struct", "string", "string", "string", "string" ]]]);
  35. dbus_method ("getPlatform", [], [ "string" ]);
  36. dbus_method ("setPlatform", [ "string" ], []);
  37.  
  38. sub new
  39. {
  40.   my $class   = shift;
  41.   my $service = shift;
  42.   my $self    = $class->SUPER::new ($service, $OBJECT_PATH);
  43.  
  44.   bless $self, $class;
  45.  
  46.   &Utils::Platform::init ();
  47.   return $self;
  48. }
  49.  
  50. sub getPlatformList
  51. {
  52.   my ($self) = @_;
  53.   my ($arr, $hash, $key);
  54.  
  55.   $hash = &Utils::Platform::get_platform_info ();
  56.  
  57.   foreach $key (keys %$hash)
  58.   {
  59.     push @$arr, [ $$hash{$key}[0],
  60.                $$hash{$key}[1],
  61.                $$hash{$key}[2],
  62.                $key ];
  63.   }
  64.  
  65.   return $arr;
  66. }
  67.  
  68. sub getPlatform
  69. {
  70.   return $Utils::Backend::tool{"platform"};
  71. }
  72.  
  73. # A directive handler that sets the currently selected platform.
  74. sub setPlatform
  75. {
  76.   my ($self, $platform) = @_;
  77.  
  78.   &Utils::Platform::set_platform ($platform);
  79. }
  80.  
  81. my $bus = &Utils::DBus::get_bus ();
  82. my $service = $bus->export_service ($Utils::Backend::DBUS_PREFIX . ".$OBJECT_NAME");
  83. my $platforms_list  = Platform->new ($service);
  84.  
  85. 1;
  86.